package liudan.archetype.server;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * Description:
 * Email: liudan@ucfgroup.com
 * Title
 * Copyright: Copyright (c) 2017
 * User: liudan
 * Created on 2017/2/25 22:32
 */
public class WebServer {

    public void serverOnStart(int port) {
        try {
            Socket socket = null;
            ServerSocket serverSocket = new ServerSocket(port);
            while (true) {
                socket = serverSocket.accept();
                new Processor(socket).start();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    public static void main(String[] args) {
        int port = 8090;
        if (args.length == 1) {
            port = Integer.parseInt(args[0]);
        }
        new WebServer().serverOnStart(port);
    }
}
